
function request(url, method, data) {
    if (method == 'post') {
        data['_token'] = $('meta[name="_token"]').attr('content');
    }
    return new Promise((resolve, reject) => {
        $.ajax({
            type: method,
            url: url,
            contentType: 'application/json;charset=utf-8',
            data: method != 'get' ? JSON.stringify(data) : data,
            success: (res) => {
                resolve(res);
            },
            error: (err) => {
                reject(err);
            },
        })
    });
}
